package com.xbongbong.saas.model;

import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.wrap.IModel;
import com.xbongbong.saas.domain.entity.OpportunityProductEntity;

import java.util.List;
import java.util.Map;

/**
 * @author long.rao
 * @version v1.0
 * @date 2019/2/23 14:27
 * @since v1.0
 */
public interface OpportunityProductModel extends IModel<OpportunityProductEntity> {
    /**
     * 机会产品数据插入
     * @param entity 供应商实体
     * @throws XbbException 异常
     * @return Integer
     * @author long.rao
     * @date 2019-02-01 15:39
     */
    @Override
    Integer insert(OpportunityProductEntity entity) throws XbbException;

    /**
     * 机会产品数据更新
     * @param entity 机会关注员工实体
     * @author long.rao
     * @date 2019-02-01 15:39
     * @throws XbbException 异常
     * @return Integer
     */
    @Override
    Integer update(OpportunityProductEntity entity) throws XbbException;

    /**
     * 机会产品数据查询多个
     * @param param 参数
     * @author long.rao
     * @date 2019-02-01 15:39
     * @return List<OpportunityProductEntity>
     */
    @Override
    List<OpportunityProductEntity> findEntitys(Map<String, Object> param);

    /**
     * 机会产品数据查询条数
     * @param param 参数
     * @author long.rao
     * @date 2019-02-01 15:39
     * @return Integer
     */
    @Override
    Integer getEntitysCount(Map<String, Object> param);

    /**
     * 机会产品数据保存
     * @param entity 机会产品实体
     * @throws XbbException 异常
     * @return Integer
     * @author long.rao
     * @date 2019-02-01 15:17
     */
    Integer save(OpportunityProductEntity entity) throws XbbException;
    /**
     * 根据机会id获取对应的类型的产品
     * @param oppId 机会id
     * @param corpid 公司ID
     * @param delIn
     * @author 吴峰
     * @date 2021/9/16 13:37
     */
    List<OpportunityProductEntity> getProductsByOppId(Long oppId, String corpid, List<Integer> delIn);
    /**
     * 根据机会id获取对应的类型的产品
     * @param oppId 机会id
     * @param corpid 公司ID
     * @author long.rao
     * @date 2019-03-02 16:20
     */
    List<OpportunityProductEntity> getProductsByOppId(Long oppId, String corpid);

    /**
     * 获取机会预估成本
     *
     * @param corpid        公司id
     * @param opportunityId 机会id
     * @return java.lang.Double
     * @author long.rao
     * @date 2019-03-04 14:17
     */
    Double getEstimateCost(String corpid, Long opportunityId);

    Integer dataConsistencyUpdate(String corpid, Long productId, String productName, String specification, String productNo);

    Long isProductSubAttrExist(String attr, String corpid, Long formId, Integer isArray);

    Integer deleteBatchByProductId(List<Long> productIdList, String corpid);

    Double summaryByAttr(String field,String corpid,  Long refId, List<Long> productIdIn);

    Double summaryByAttrFromOutSide(String field,String corpid,  Long refId, List<Long> productIdIn);

    Long countProductSub(String attr, String corpid, Long formId, Integer isArray);

    List<OpportunityProductEntity> getProductWithSubData(String attr, String corpid, Long formId, Integer isArray, Long idGte, Integer limit);

    /**
     * 批量删除
     * @param deleteList
     * @param corpid
     * @param del
     * @return
     */
    Integer deleteBatch(List<Long> deleteList, String corpid, Integer del);
    /**
     * 批量编辑
     * @param list
     * @param corpid
     * @return
     */
    Integer updateMulti(List<OpportunityProductEntity> list, String corpid);

    /**
     * 批量插入
     * @param insertList
     * @return java.lang.Integer
     * @author 吴峰
     * @date 2022/3/17 10:23
     * @throws XbbException
     */
    Integer insertBatch(List<OpportunityProductEntity> insertList) throws XbbException;
}
